﻿using System;
using System.Collections.Generic;
using System.Data;

using System.Text;
using System.Web.UI.WebControls;
using Module.Core.EntitiesInfo;
using Module.DataAccess;
using Module.EntitiesInfo;

namespace Module.BusinessLogic
{
  public  class AdvertisementPositionsBL
    {
      public static int Insert(AdvertisementPositionsInfo advertisementPositionsInfo)
        {
            try
            {
                return new AdvertisementPositionsDB().Insert(advertisementPositionsInfo);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

      public static void Update(AdvertisementPositionsInfo advertisementPositionsInfo)
        {
            try
            {
                new AdvertisementPositionsDB().Update(advertisementPositionsInfo);
            }
            catch (Exception ex)
            {
                throw;
            }

        }


      public static void Delete(int positionID)
        {
            try
            {
                new AdvertisementPositionsDB().Delete(positionID);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static List<AdvertisementPositionsInfo> Select(int type, string param_1, string param_2)
        {
            try
            {
                return ObjectHelper.FillCollection<AdvertisementPositionsInfo>(new AdvertisementPositionsDB().Select(type, param_1, param_2));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public static List<AdvertisementPositionsInfo> Select(int type, string param_1)
        {
            try
            {
                return ObjectHelper.FillCollection<AdvertisementPositionsInfo>(new AdvertisementPositionsDB().Select(type, param_1));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public static List<AdvertisementPositionsInfo> Select(int type)
        {
            try
            {
                return ObjectHelper.FillCollection<AdvertisementPositionsInfo>(new AdvertisementPositionsDB().Select(type));
            }
            catch (Exception ex)
            {
                throw;
            }
        }

      
        public static DataTable SelectTbl(int? type, string para_1, string para_2)
        {
            try
            {
                return new AdvertisementPositionsDB().SelectTbl(type, para_1, para_2);
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        public static DataTable SelectTbl(int? type, string para_1)
        {
            try
            {
                return new AdvertisementPositionsDB().SelectTbl(type, para_1);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public static DataTable SelectTbl(int? type)
        {
            try
            {
                return new AdvertisementPositionsDB().SelectTbl(type);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
      

        public static AdvertisementPositionsInfo GetInfo(int type, string para_1, string para_2)
        {
            try
            {
                AdvertisementPositionsInfo info;
                info = ObjectHelper.FillObject<AdvertisementPositionsInfo>(new AdvertisementPositionsDB().Select(type, para_1,para_2));
                if (info != null)
                    return info;
                return null;
            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Selects all records from the Advertisement_Positions table.
        /// </summary>
        public static CHRTList<AdvertisementPositionsInfo> SelectAll()
        {
            try
            {
                return new AdvertisementPositionsDB().SelectAll();
            }
            catch (Exception ex)
            {
                throw;
            }

        }


        public static int GetCount(string keysearch, DateTime starDatetime, DateTime endDatetime, int beginRow, int endRow)
        {
            try
            {
                return new AdvertisementPositionsDB().GetCount(keysearch,starDatetime, endDatetime, beginRow, endRow);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static DataTable Search(string keysearch, DateTime starDatetime, DateTime endDatetime, int beginRow, int endRow, string orderByColumn)
        {
            try
            {
                return new AdvertisementPositionsDB().Search(keysearch, starDatetime, endDatetime, beginRow, endRow, orderByColumn);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static void FillDropList(ListControl ctrlList, string selectedValue)
        {
            try
            {
                DataTable dt = new DataTable();
                dt = SelectTbl(1, "", "");
                //  ctrlList.Items.Insert(0, new ListItem("--------Vị trí quảng cáo--------", "1"));
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {

                        ListItem _item = new ListItem(dr["Title"].ToString(), dr["PositionID"].ToString());
                        if (_item.Value == selectedValue) _item.Selected = true;
                        ctrlList.Items.Add(_item);
                    }
                }

            }
            catch (Exception ex)
            {
                throw;
            }
        }


     }

}
